#ifndef SHADER_SYSTEM_H_
#define SHADER_SYSTEM_H_

#include "../Common/GlobalDefines.h"
#include "../Common/ZSingleton.h"
#include "Shader.h"

#ifdef RENDER_OPENGL

#include <QGLShaderProgram>

GLOBAL_NAMESPACE_BEGIN

class ShaderSystem : public Singleton<ShaderSystem>
{
public:
    ShaderSystem();
    ~ShaderSystem();

    void init();
    void destroy();
    void refresh();
    void bind(QWidget* parent);

    void addShader(GLShader* shader);

    GLShader* createShader(const char* shaderType, const char* shaderName, const char* shaderFile);
    QGLShaderProgram* createProgram();
    QGLShaderProgram* getCurrentShaderProgram();

private:
    std::vector<QGLShaderProgram*>  programs_;
    std::vector<GLShader*>          shaders_;
    int         currentProgram_;
    int         currentVSShader_;
    int         currentFSShader_;
    int         currentGSShader_;
};

GLOBAL_NAMESPACE_END

#endif

#endif//SHADER_SYSTEM_H_